﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;

namespace Dabr.NET
{
    public partial class DabrPage : System.Web.UI.Page
    {
        const string ApiNew = "http://api.twitter.com/1.1/";
        const string ApiOld = "http://api.twitter.com/1/";

        DateTime DabrStart;

        protected string BaseURL
        {
            get
            {
                return string.Format("{0}://{1}{2}/",
                    Request.Url.Scheme,
                    Request.Url.Authority,
                    HttpRuntime.AppDomainAppVirtualPath);
            }
        }

        protected void LogoutPage()
        {
            // TODO: Logout Page code
            throw new NotImplementedException();
        }

        protected void AboutPage()
        {
            string about;
            about = PHPLegacyFunctions.FileGetContents("Include\\_about.html");
            // TODO: About Page code
            throw new NotImplementedException();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            DabrStart = DateTime.Now;
            #region Cache refusal on header
            // TODO: Verify whether this works with Firefox.
            // TODO: Check whether Pragma: no-cache is really unnecessary.
            Response.Cache.SetExpires(new DateTime(1997, 07, 26, 05, 00, 00, DateTimeKind.Utc));
            Response.Cache.SetLastModified(DateTime.Now);
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetNoStore();
            #endregion
            //require 'config.php'; -> Include/Configuration.cs
            //require 'common/browser.php'; -> Include/Browser.cs
            //require 'common/menu.php'; -> Include/Menu.cs
            InitializeMenu();
            //require 'common/user.php';
            //require 'common/theme.php';
            //require 'common/twitter.php';
            //require 'common/lists.php';
            //require 'common/settings.php';

            /*
                menu_register(array (
	                'about' => array (
		                'callback' => 'about_page',
	                ),
	                'logout' => array (
		                'security' => true,
		                'callback' => 'logout_page',
	                ),
                ));

                function logout_page() {
	                user_logout();
	                header("Location: " . BASE_URL);
	                exit;
                }

                function about_page() {
	                $content = file_get_contents('about.html');
	                theme('page', 'About', $content);
                } */
            DetectBrowser();
            ExecuteActiveHandler();
        }


    }
}